package com.jj.lib;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.jj.adapter.BaseRecyclerAdapter;

/**
 * Created by qmsoft05 on 2017/3/20.
 */

public class BAdapter extends BaseRecyclerAdapter<AppModel> {

    public BAdapter(Context context, int mode) {
        super(context, mode);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateDefaultViewHolder(ViewGroup parent, int type) {
        return new BHolder(mInflater.inflate(R.layout.item_b, parent, false));
    }

    @Override
    protected void onBindDefaultViewHolder(RecyclerView.ViewHolder holder, AppModel item, int position) {
        if (holder instanceof BHolder) {
            BHolder her = ((BHolder) holder);
            her.iv_logo.setImageDrawable(item.getIcon());
            her.iv_package.setText(item.getPackages());
            her.tv_title.setText(item.getTitle());
        }
    }

    private static class BHolder extends RecyclerView.ViewHolder {
        ImageView iv_logo;
        TextView tv_title;
        TextView iv_package;

        public BHolder(View itemView) {
            super(itemView);
            iv_logo = (ImageView) itemView.findViewById(R.id.iv_logo);
            tv_title = (TextView) itemView.findViewById(R.id.tv_title);
            iv_package = (TextView) itemView.findViewById(R.id.iv_package);
        }
    }
}
